package com.kwdb.sdk.config;

/**
 * 客户端配置类 - 基于gRPC的配置
 */
public class ClientConfig {
    
    private String host = "localhost";
    private int port = 9090;  // gRPC默认端口
    private int connectionTimeout = 5000;
    private int readTimeout = 10000;
    private int writeTimeout = 10000;
    private int threadPoolSize = 10;
    private int batchSize = 1000;
    private int batchTimeout = 1000; // 毫秒
    private boolean autoConnect = true;
    private int maxRetries = 3;
    private int retryInterval = 1000; // 毫秒
    private boolean enableCompression = true;
    private boolean enableTls = false;
    private String clientId = "kwdb-client-" + System.currentTimeMillis();
    private int maxInboundMessageSize = 4 * 1024 * 1024; // 4MB
    private int maxInboundMetadataSize = 8 * 1024; // 8KB
    private boolean keepAlive = true;
    private int keepAliveTime = 30; // 秒
    private int keepAliveTimeout = 5; // 秒
    private boolean keepAliveWithoutCalls = true;
    
    public ClientConfig() {}
    
    public ClientConfig(String host, int port) {
        this.host = host;
        this.port = port;
    }
    
    // Getters and Setters
    public String getHost() {
        return host;
    }
    
    public ClientConfig setHost(String host) {
        this.host = host;
        return this;
    }
    
    public int getPort() {
        return port;
    }
    
    public ClientConfig setPort(int port) {
        this.port = port;
        return this;
    }
    
    public int getConnectionTimeout() {
        return connectionTimeout;
    }
    
    public ClientConfig setConnectionTimeout(int connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
        return this;
    }
    
    public int getReadTimeout() {
        return readTimeout;
    }
    
    public ClientConfig setReadTimeout(int readTimeout) {
        this.readTimeout = readTimeout;
        return this;
    }
    
    public int getWriteTimeout() {
        return writeTimeout;
    }
    
    public ClientConfig setWriteTimeout(int writeTimeout) {
        this.writeTimeout = writeTimeout;
        return this;
    }
    
    public int getThreadPoolSize() {
        return threadPoolSize;
    }
    
    public ClientConfig setThreadPoolSize(int threadPoolSize) {
        this.threadPoolSize = threadPoolSize;
        return this;
    }
    
    public int getBatchSize() {
        return batchSize;
    }
    
    public ClientConfig setBatchSize(int batchSize) {
        this.batchSize = batchSize;
        return this;
    }
    
    public int getBatchTimeout() {
        return batchTimeout;
    }
    
    public ClientConfig setBatchTimeout(int batchTimeout) {
        this.batchTimeout = batchTimeout;
        return this;
    }
    
    public boolean isAutoConnect() {
        return autoConnect;
    }
    
    public ClientConfig setAutoConnect(boolean autoConnect) {
        this.autoConnect = autoConnect;
        return this;
    }
    
    public int getMaxRetries() {
        return maxRetries;
    }
    
    public ClientConfig setMaxRetries(int maxRetries) {
        this.maxRetries = maxRetries;
        return this;
    }
    
    public int getRetryInterval() {
        return retryInterval;
    }
    
    public ClientConfig setRetryInterval(int retryInterval) {
        this.retryInterval = retryInterval;
        return this;
    }
    
    public boolean isEnableCompression() {
        return enableCompression;
    }
    
    public ClientConfig setEnableCompression(boolean enableCompression) {
        this.enableCompression = enableCompression;
        return this;
    }
    
    public boolean isEnableTls() {
        return enableTls;
    }
    
    public ClientConfig setEnableTls(boolean enableTls) {
        this.enableTls = enableTls;
        return this;
    }
    
    public String getClientId() {
        return clientId;
    }
    
    public ClientConfig setClientId(String clientId) {
        this.clientId = clientId;
        return this;
    }
    
    public int getMaxInboundMessageSize() {
        return maxInboundMessageSize;
    }
    
    public ClientConfig setMaxInboundMessageSize(int maxInboundMessageSize) {
        this.maxInboundMessageSize = maxInboundMessageSize;
        return this;
    }
    
    public int getMaxInboundMetadataSize() {
        return maxInboundMetadataSize;
    }
    
    public ClientConfig setMaxInboundMetadataSize(int maxInboundMetadataSize) {
        this.maxInboundMetadataSize = maxInboundMetadataSize;
        return this;
    }
    
    public boolean isKeepAlive() {
        return keepAlive;
    }
    
    public ClientConfig setKeepAlive(boolean keepAlive) {
        this.keepAlive = keepAlive;
        return this;
    }
    
    public int getKeepAliveTime() {
        return keepAliveTime;
    }
    
    public ClientConfig setKeepAliveTime(int keepAliveTime) {
        this.keepAliveTime = keepAliveTime;
        return this;
    }
    
    public int getKeepAliveTimeout() {
        return keepAliveTimeout;
    }
    
    public ClientConfig setKeepAliveTimeout(int keepAliveTimeout) {
        this.keepAliveTimeout = keepAliveTimeout;
        return this;
    }
    
    public boolean isKeepAliveWithoutCalls() {
        return keepAliveWithoutCalls;
    }
    
    public ClientConfig setKeepAliveWithoutCalls(boolean keepAliveWithoutCalls) {
        this.keepAliveWithoutCalls = keepAliveWithoutCalls;
        return this;
    }
}
